

function addformprofileform()
{

   
    $("#addform").append('<div id="feature'+rowdiv+'" class="itPlg addProfilePlug featureclass">'+dataform['profileform']+"</div>");
    var rownow=rowdiv;

   
  
  var rowgnow=1;
  
  
   $('#feature'+rownow+' .uploadbutton').iuploader({
         'link':serviceinfo+'iupload',
         'accept':'image/*',
         'group':rowgnow,

         'type':['jpg', 'jpeg', 'png', 'gif'],
         'onUploadFinish':function(filename,filelink,setting){
         
         
         
         
         getpopupboxresize(600,600,filelink,setting['originalwidth'],setting['originalheight'],
         
         function(filename2,filelink2,width2,height2,imgmid2){
         var rowgnow2=setting['group'];        
         $('#feature'+rownow+' .image'+rowgnow2+' .plgAreaThumbnail').html('<a target="_blank" href="'+filelink+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="150" width="150" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="filelink[]"]').val(filelink);
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="filelinkcrop[]"]').val(filelink2);                 
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="fileold[]"]').val(setting.fileold);      
         $("#width-"+setting.id).val(setting.originalwidth);
         $("#height-"+setting.id).val(setting.originalheight);      
         $("#imgmid-"+setting.id).val(setting.imgmid);       
         $("#simgmid-"+setting.id).val(imgmid2);               
         $("#widthcrop-"+setting.id).val(width2);
         $("#heightcrop-"+setting.id).val(height2);    
         
          closepopup();  
         }
         ,setting['imgmid']
         
         );
         //alert(filename);
         }
   });
  
   $('#feature'+rownow+' .cloudbutton').click(function() {
          //console.log("testdata");
          //var rowgnow3=rowgnow;
          var rowgnow3=1;
        //alert("Handler for .click() called.");
          getpopupcloud(
          function(filename2,filelink2,width2,height2,imgmid2,index2){ 

        $('#feature'+rownow+' .image'+rowgnow3+' .plgAreaThumbnail').html('<a target="_blank" href="'+$('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val()+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="150" width="150" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val(imgmid2);
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val(filelink2);                                    
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val(width2);         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val(height2);

        closepopup();  

          
          },
          
          
          function(filename,filelink,width,height,imgmid,indexnow){
            
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val(filelink);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val(imgmid);           
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val(width);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val(height);
            

          
          }
          ,
          rowgnow
          ,600
          ,600
          
          );

   });
   
   $('#feature'+rownow+' .deletebutton').click(function() {
   
   var rowgnow3=1;
   

   $('#feature'+rownow+' .image'+rowgnow3+' .plgAreaThumbnail a').remove();
   
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val('');
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val('');           
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val('');
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val('');
   
   
   
    $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val('');
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val('');                                    
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val('');         
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val('');
   
   });
   
   $('#feature'+rownow+' .linkbutton').click(function() {
   var rowgnow3=1;
   //console.log("test");
   
   getpopuplink(
          function(filename2,filelink2,width2,height2,imgmid2,index2){ 
          
          
         $('#feature'+rownow+' .image'+rowgnow3+' .plgAreaThumbnail').html('<a target="_blank" href="'+$('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val()+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="150" width="150" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val(imgmid2);
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val(filelink2);                                    
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val(width2);         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val(height2);
        // $.colorbox.close("User added succesfully"); 
        closepopup();  
          
          },
          function(filename,filelink,width,height,imgmid,indexnow){
            

            $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val(filelink);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val(imgmid);           
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val(width);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val(height);
            

          
          }
          ,
          rowgnow
          ,600
          ,600
   );
   
   });
   
   $('#feature'+rownow+' .deleterowbutton').click(function(){
   
    $('#feature'+rownow).remove();
    
   });
  
  
    
    
    
    
    rowdiv++;

}
function saveformprofileform(id,plugid)
{
   var obj={};
   obj={
   plugid:plugid,
   simgmid:$("#"+id+' input[name="simgmid[]"]').val(),
   imgmid:$("#"+id+' input[name="imgmid[]"]').val(),
   firstname:$("#"+id+' input[name="firstname"]').val(),
   lastname:$("#"+id+' input[name="lastname"]').val(),
   nickname:$("#"+id+' input[name="nickname"]').val(),
   classroom:$("#"+id+' input[name="classroom"]').val(),
   room:$("#"+id+' input[name="room"]').val(),
   company:$("#"+id+' input[name="company"]').val(),
   jobtitle:$("#"+id+' input[name="jobtitle"]').val(),
   jobdesc:$("#"+id+' textarea[name="jobdesc"]').val()
   
   
   
   };
   
   return obj;


}
function getformprofileform(arraydata)
{

  var code = '<div class="ldIt wrpFrmLd clBg4">\n';
code += '<div class="wrpHdInfoGen mgBtm10">\n';
code += '<h2 class="clTxt2 fs04 boldGen">Profile</h2>\n';
code += '</div>\n';
code += '<table class="tbGenInfo tbFrmLd clTxt3 fs03">\n';
code += '<tbody><tr>\n';
code += '<th>Profile Image</th>\n';
code += '<td><a target="_blank" href="'+arraydata['img']['newpath']+'"><img width="100" height="100" src="'+arraydata['simg']['newpath']+'" alt="" class="pfImgPlg"></a></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>First Name</th>\n';
code += '<td>'+arraydata['firstname']+'</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Lastname</th>\n';
code += '<td>'+arraydata['lastname']+'</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Nickname</th>\n';
code += '<td>'+arraydata['nickname']+'</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Class</th>\n';
code += '<td>'+arraydata['classroom']+'</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Room/Group</th>\n';
code += '<td>'+arraydata['room']+'</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Company</th>\n';
code += '<td>'+arraydata['company']+'</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Job Title</th>\n';
code += '<td>'+arraydata['jobtitle']+'</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Job Description</th>\n';
code += '<td>'+arraydata['jobdesc']+'</td>\n';
code += '</tr>\n';
code += '</tbody></table>\n';
code += '</div>';

return code;


}
 function editformprofileform(datarow)
 {
     addformprofileform();
     var rownow= rowdiv-1;
     var rowgnow2=1;
    $('#feature'+rownow+' .image'+rowgnow2+' .plgAreaThumbnail').html('<a target="_blank" href="'+datarow.img.newpath+'?t='+Math.floor((Math.random()*100000)+1)+'"><img  width="150" height="150" src="'+datarow.simg.newpath+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
    $('#feature'+rownow+' .image'+rowgnow2+' input[name="imgmid[]"]').val(datarow.imgmid);
    $('#feature'+rownow+' .image'+rowgnow2+' input[name="simgmid[]"]').val(datarow.simgmid);
    
    
    $('#feature'+rownow+'  input[name="firstname"]').val(datarow.firstname);
    $('#feature'+rownow+'  input[name="lastname"]').val(datarow.lastname);
    $('#feature'+rownow+'  input[name="nickname"]').val(datarow.nickname);
    $('#feature'+rownow+'  input[name="classroom"]').val(datarow.classroom);
    $('#feature'+rownow+'  input[name="room"]').val(datarow.room);
    $('#feature'+rownow+'  input[name="company"]').val(datarow.company);
    $('#feature'+rownow+'  input[name="jobtitle"]').val(datarow.jobtitle);
    $('#feature'+rownow+'  textarea[name="jobdesc"]').val(datarow.jobdesc);

  
 }